package daobeauty.interceptor.returntype.handler.impl;

import java.util.LinkedHashSet;
import java.util.List;

import daobeauty.interceptor.returntype.handler.ReturnTypeHandler;

/**
 * ReturnTypeHandler for methods returning a LinkedHashSet.
 * 
 * @author M. Serhat Cinar
 *
 */
public class LinkedHashSetReturnType implements ReturnTypeHandler<LinkedHashSet> {

	/**
	 * Creates a new LinkedHashSet and adds all elements of the List to the LinkedHashSet.
	 * 
	 * @see daobeauty.interceptor.returntype.handler.ReturnTypeHandler#convert(java.util.List)
	 */
	@SuppressWarnings("unchecked")
	public LinkedHashSet convert(List result) {
		return new LinkedHashSet(result);
	}

	/**
	 * Creates a new LinkedHashSet and adds the Object to the LinkedHashSet.
	 * 
	 * @see daobeauty.interceptor.returntype.handler.ReturnTypeHandler#convert(java.lang.Object)
	 */
	@SuppressWarnings("unchecked")
	public LinkedHashSet convert(Object result) {
		final LinkedHashSet set = new LinkedHashSet();
		set.add(result);
		return set;
	}
}
